<template>
  <div class="pay" id="pay">
    <div class="pay_1">
      <div class="top">
        <div class="top_1" v-if="type != 'change'">
          <div style="width: 260px">
            订单编号：{{ message.id }}<span></span>
          </div>
          <div style="width: 260px">
            订单状态：{{ message.orderStatus == "unpaid" ? "待支付" : ""
            }}<span></span>
          </div>
          <div style="width: 260px" >
            订单金额：{{ message.orderPayAmount }}<span></span>
          </div>
        </div>
        <div class="top_1" v-if="type == 'change'">
          <div style="width: 260px">
            订单编号：{{ message.changeRefundS[0].orderId }}<span></span>
          </div>
          <!-- <div style="width: 260px">
            订单状态：{{ message.orderStatus == "waitPay" ? "待支付" : ""
            }}<span></span>
          </div> -->
          <div style="width: 260px">
            创建时间：{{ message.createTime }}<span></span>
          </div>
        </div>
        <!-- 支付方式 -->
        <div class="seven">
          <div class="tuo">
            <div class="tuo-2"></div>
            <span>支付方式</span>
          </div>
          <el-form
            size="mini"
            :inline="true"
            :data="mode"
            :model="pattern"
            class="others"
            :rules="patternrules"
          >
            <div class="five-3" style="display:block">
              <div class="WeChat1" v-if="type != 'change'">
                <div class="five_t" >
                  会员预留余额
                  <span style="font-size: 16px; color: #ef8249">
                    ￥{{ numFilter(message.userMoneyNumber * 1) }}
                  </span>
                </div>
                <div class="two-1"  style="margin-right: 10px">
                  本次使用余额
                  <el-input
                    style="width: 80px"
                    size="mini"
                    v-model="useManey"
                    placeholder=""
                    @input="inputaside($event,'useManey')"
                  >
                  </el-input>
                </div>
                <div class="five_t">
                  使用后余额
                  <span style="font-size: 16px; color: #ef8249">
                    ￥{{ numFilter(message.userMoneyNumber - useManey) }}
                  </span>
                </div>
              </div>
              <div class="WeChat1" v-if="type != 'change'">
                <div class="five_t" >
                  会员预留金币
                  <span style="font-size: 16px; color: #ef8249">
                    ￥{{ numFilter(message.userSpeciesNumber * 1) }}
                  </span>
                </div>
                <div class="two-1"  style="margin-right: 10px">
                  本次使用金币
                  <el-input
                    style="width: 80px"
                    size="mini"
                    v-model="usegold"
                    placeholder=""
                    @input="inputaside($event,'usegold')"
                  >
                  </el-input>
                </div>
                <div class="five_t">
                  使用后金币
                  <span style="font-size: 16px; color: #ef8249">
                    ￥{{ numFilter(message.userSpeciesNumber - usegold) }}
                  </span>
                </div>
              </div>
              <div class="WeChat1">
                <div class="five_t" v-if="type != 'change'">
                  仍需支付余额<span style="font-size: 16px; color: #ef8249">
                    ￥{{ numFilter(message.orderPayAmount - usegold - useManey) }}
                  </span>
                </div>
                <div class="five_t" v-if="type == 'change'">
                  需要支付的差价
                  <span style="font-size: 16px; color: #ef8249">
                  ￥{{ changeAmount}}</span>
                </div>
              </div>
              <div v-if="pattern.pays == '3'">
                话术：<span class="WeChat"
                  >稍后加您的微信，你同意后给您发个二维码
                  长按识别后输入金额支付即可 请支付成功后通知我们查收。</span
                >
              </div>
            </div>
            <div class="five-2">
              <el-form-item label="支付方式" label-width="80px">
                <el-select
                  clearable
                  size="mini"
                  v-model="pattern.pays"
                  style="width: 140px"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in payList"
                    :key="item.id"
                    :label="item.names"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="已有银行卡" v-if="pattern.pays == '0'" label-width="120px" prop="pays">
                <el-select
                  clearable
                  size="mini"
                  v-model="pattern.bankId"
                  @change="changeBankId"
                  @clear="changeBankId"
                  style="width: 140px"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in bankSelList"
                    :key="item.bankId"
                    :label="item.bankName"
                    :value="item.bankId"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item v-if="pattern.pays == '0'">
                <el-button type="primary" :loading="bankSaveLoadIng" :disabled="bankSaveLoadIng" @click="getaddUsrBackCard()">添加银行卡</el-button>
              </el-form-item>
            </div>
            <div v-if="pattern.pays == '0'">
              <el-form-item label="银行卡类型" label-width="100px">
                <el-select
                  size="mini"
                  v-model="chosecardType"
                  placeholder="请选择"
                  clearable
                >
                  <el-option
                    v-for="item in bankcardList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="姓名" label-width="80px" prop="userName">
                <el-input
                  v-model="pattern.userName"
                  placeholder="请输入姓名"
                  prop="userName"
                >
                </el-input>
              </el-form-item>
              <el-form-item label="证件号" label-width="80px" prop="cardNumber">
                <el-input
                  v-model="pattern.cardNumber"
                  placeholder="请输入证件号"
                >
                </el-input>
              </el-form-item>
              <el-form-item label="卡号" label-width="80px" prop="cardId">
                <el-input v-model="pattern.cardId" placeholder="请输入卡号">
                </el-input>
              </el-form-item>
              <!-- <el-form-item
                label="银行编码"
                v-show="cvvShow"
                label-width="80px"
              >
                <el-input v-model="pattern.bankCode" placeholder=""></el-input>
              </el-form-item> -->
              <el-form-item label="有效期" label-width="80px" v-show="cvvShow">
                <el-date-picker
                  v-model="pattern.creditCardTime"
                  type="date"
                  placeholder="选择日期"
                  value-format="yyyy-MM"
                >
                </el-date-picker>
              </el-form-item>
              <el-form-item label="cvv" label-width="80px" v-show="cvvShow">
                <el-input v-model="pattern.cvv"> </el-input>
              </el-form-item>
              <el-form-item label="手机" label-width="80px" prop="phone">
                <el-input v-model="pattern.phone" placeholder="请输入手机号码">
                </el-input>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="top_1">
          <div>操作人：<span></span></div>
        </div>
      </div>
      <div
        style="
          margin-left: 20px;
          margin-right: 20px;
          margin-bottom: 20px;
          margin-top: 20px;
        "
      >
        <div class="wenzi">乘客信息</div>
        <el-table
          size="mini"
          :data="tableData"
          border
          style="width: 100%"
        >
          <el-table-column prop="passengerName" label="乘客姓名" width="100">
          </el-table-column>
          <el-table-column prop="passengerType" label="乘客类型" width="80">
            <template slot-scope="scope">
              <template v-if="scope.row.passengerType == 'children'">儿童
              </template>
              <template v-else-if="scope.row.passengerType == 'baby'">婴儿
              </template>
              <template v-else>成人</template>
          </template>
          </el-table-column>
          <el-table-column prop="idNumber" label="乘客证件号" width="150">
          </el-table-column>
          <el-table-column prop="ticketAmount" label="票面价" width="80">
          </el-table-column>
          <!-- <el-table-column prop="passengerType" label="税费" width="70">
          </el-table-column> -->
          <!-- <el-table-column prop="name" label="代理费" width="70">
          </el-table-column> -->
          <!-- <el-table-column prop="name" label="直减费" width="70">
          </el-table-column> -->
          <el-table-column
            prop="changeAmount"
            v-if="type == 'change'"
            label="改期费"
            width="70"
          >
          </el-table-column>
          <el-table-column label="PNR" width="80">
            <template>
              <span>{{ message.pnr }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderId" label="单号" width="160">
          </el-table-column>
          <el-table-column prop="orderStatus" label="客票状态">
            <template slot-scope="scope">
               {{scope.row.orderStatus | orderStatus}}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div
        class="top"
        style="margin-left: 20px; margin-right: 20px; margin-bottom: 20px"
      >
        <div class="wenzi">行程信息</div>
        <el-table
          size="mini"
          :data="tableData"
          border
          style="width: 100%"
        >
          <el-table-column prop="flightNo" label="航班号" width="90">
          </el-table-column>
          <el-table-column prop="departureTime" label="起飞时间" width="150">
          </el-table-column>
          <el-table-column prop="arriveTime" label="到达时间" width="150">
          </el-table-column>
          <el-table-column
            prop="departureCity"
            label="出发地"
            width="80"
          >
            <template slot-scope="scope">
               {{scope.row.departureCity || scope.row.departureCityName }}
            </template>
          </el-table-column>
          <el-table-column prop="arriveCity" label="到达地" width="80">
            <template slot-scope="scope">
               {{scope.row.arriveCity || scope.row.arriveCityName }}
            </template>
          </el-table-column>
          <el-table-column
            prop="departureAirportName"
            label="出发机场"
            width="80"
          >
            <template slot-scope="scope">
               {{scope.row.departureAirportName + (scope.row.departureAirportTerminal?scope.row.departureAirportTerminal:'')}}
            </template>
          </el-table-column>
          <el-table-column prop="arriveAirportName" label="到达机场" width="80">
            <template slot-scope="scope">
               {{scope.row.arriveAirportName +  (scope.row.arriveAirportTerminal?scope.row.arriveAirportTerminal:'') }}
            </template>
          </el-table-column>
          <el-table-column prop="cabin" label="舱位" width="70">
          </el-table-column>
          <el-table-column prop="flightType" label="机型" width="100">
          </el-table-column>
          <!-- <el-table-column prop="name" label="退改签规定" width="100">
          </el-table-column> -->
          <el-table-column
            prop="baggage"
            label="行李(成人 儿童)"
            width="130"
          >
          </el-table-column>
          <el-table-column prop="name" label="权益" width="110">
          </el-table-column>
        </el-table>
      </div>
      <el-dialog
        title="提示"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose"
      >
        <!-- <div class="index-body" v-if="qrcode"> -->
        <div class="index-body">
          请将此二维码发给会员
          <div class="qrcode">
            <img :src="qrcode" alt="" />
            <!-- 这里的src的值就是生成的二维码的地址 -->
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="payfn()">确 定</el-button>
        </span>
      </el-dialog>
      <div class="bottom">
        <el-button
          style="background-color: #499d93; color: #fff"
          @click="endorse"
          >我要支付</el-button
        >
        <el-button @click="cancel">取消</el-button>
      </div>
    </div>
    <!-- <div class="fli_box1" id="pay" v-loading="loading" element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.5)" :data="objPnr"
      style="width: 100%"></div> -->
  </div>
</template>

<script>
import QRCode from "qrcode";
import { Loading } from "element-ui";
export default {
  name: "pay",
  components: {
    Loading,
  },
  data() {
    return {
      usegold: 0,
      useManey: 0,
      changeAmount:0, // 改签的差价
      Querydata: {},
      // 支付方式所有绑定的信息
      // 支付方式
      mode: {},
      bankSaveLoadIng:false,
      pattern: {
        bankId:"",
        bankCode: "",
        phone: "",
        payment: 0,
        pays: "",
        userName: "",
        cardNumber: "",
        cardId: "",
        cvv: "",
        period: "",
        creditCardTime: "",
      },
      // 银行卡输入框验证
      patternrules: {
        userName: [
          {
            required: true,
            message: "请输入收件姓名",
            trigger: "change",
          },
        ],
        phone: [
          {
            required: true,
            message: "请输入手机号",
            trigger: "change",
          },
        ],
        cardNumber: [
          {
            required: true,
            message: "请输入证件号",
            trigger: "change",
          },
        ],
        cardId: [
          {
            required: true,
            message: "请输入卡号",
            trigger: "change",
          },
        ],
        // payment: [
        //   {
        //     required: true,
        //     message: "请选择收款方式",
        //     trigger: "change",
        //   },
        // ],
        pays: [
          {
            required: true,
            message: "请选择支付方式",
            trigger: "change",
          },
        ],
      },
      //总部收款下拉框
      paymentList: [
        {
          id: 0,
          names: "总部收款",
        },
      ],
      bankSelList:[],
      // 银行卡类型
      bankcardList: [
        {
          value: "creditcard",
          label: "信用卡",
        },
        {
          value: "debitcard",
          label: "借记卡",
        },
      ],
      tapycard: "",
      chosecardType: "",
      cvvShow: "",

      // 支付方式下拉菜单
      payList: [
        {
          id: 0,
          names: "银行卡",
        },

        // {
        //   id: 2,
        //   names: "语音支付",
        // },
        {
          id: 3,
          names: "银联二维码支付",
        },
      ],
      money: 0,
      // 扣预留款
      moneyInput() {
        console.log(this.money);
        console.log(payamount);
        this.payamount = this.payamount - this.money;
      },
      // 卡类型
      depositcard: false,
      bankcard: false,
      GoSearchWhere: this.$route.params.GoSearchWhere,
      Querydata: this.$route.params.Querydata,
      payamount: this.$route.params.payamount,
      url: "https://qr-test2.chinaums.com/bills/qrCode.do?id=31942204267644957131195222", //识别二维码后跳转的地址或文本
      qrcode: "", //存储二维码图片的路径
      items: {},
      olgData: [],
      tabs: [],
      // orderId: this.$route.params.orderId,
      type: this.$route.params.type ? this.$route.params.type : "",
      message: {},
      tableData:[],
      dialogVisible: false,
      orderId: this.$route.params.orderId,
    };
  },
  props: {},
  components: {},
  watch: {
    // 监听银行卡类型方式
    chosecardType(nV, oV) {
      console.log(nV);
      if (nV == "creditcard") {
        this.tapycard = nV;
        this.cvvShow = true;
        console.log(this.tapycard);
      } else if (nV == "debitcard") {
        this.cvvShow = false;
        this.tapycard = nV;

        console.log(this.tapycard);
      }
    },
  },
  methods: {
    getaddUsrBackCard(){
      this.bankSaveLoadIng = true;
      let parma = {
          //用户id
          userId:this.message.userId,
          cardholder: this.pattern.userName, //持卡人姓名号
          cardNumber: this.pattern.cardId, //银行卡号
          cardType: this.tapycard,
          userType:"ZGJMSFZ",
          reservePhone: this.pattern.phone, //银行卡预留手机
          userCertificate: this.pattern.cardNumber, //身份证号
      };
      if( this.type == "creditcard") parma["CVV2"] = this.cardList.Cvv2
      if( this.type == "creditcard") parma["creditFailureDate"] = this.cardList.creditCardTime
      if( this.type == "creditcard") parma["bankCode"] = this.cardList.bankCode
      this.$axios.getBankCardById({
        cardNumber:parma.cardNumber
      }).then((res)=>{
        this.bankSaveLoadIng = false;
        if(res.code == "00000"){
          parma["bankId"] = res.data.id;
          parma["bankName"] = res.data.bankName;
          this.$axios.getaddUsrBackCard(parma).then((res)=>{
            if (res.code == "00000") {
              this.$message({
                message: "新增成功",
                type: "success",
              });
              this.getUsrBackCardList();
            }
          })
        }
      })
    },
    getUsrBackCardList(){
      this.$nextTick(()=>{
        this.$axios.getUsrBackCardList({userId: this.message.userId,}).then((res)=>{
          if(res.code == "00000"){
            this.bankSelList = [].concat(res.data) 
          }else{
            console.log("错误")
          }
        })
      })
    },
    changeBankId(val){
      this.pattern.bankId = val;
      let obj = {};
      if(val){
        obj = this.bankSelList.filter((item)=>{
          if(item.bankId == val) return item;
        })[0];
      }
      if(obj.cardholder) this.pattern.userName = obj.cardholder;
      else this.pattern.userName = "";
      if(obj.cardNumber) this.pattern.cardId = obj.cardNumber;
      else this.pattern.cardId = "";
      if(obj.cardType) this.chosecardType = obj.cardType;
      if(obj.cardType) this.tapycard = obj.cardType;
      else this.pattern.cardType = "";
      if(obj.userCertificate) this.pattern.cardNumber = obj.userCertificate;
      else this.pattern.cardNumber = "";
      if(obj.reservePhone) this.pattern.phone = obj.reservePhone;
      else this.pattern.phone = "";
      if(obj.cvv2) this.pattern.cvv = obj.cvv2;
      else this.pattern.cvv2 = "";
      if(obj.creditFailureDate && obj.creditFailureDate != "请选择有效期") this.pattern.creditCardTime = obj.creditFailureDate;
      else this.pattern.creditCardTime = "";
      if(obj.bankCode) this.pattern.bankCode = obj.bankCode;
      else this.pattern.bankCode = "";
    },
    numFilter(value) {
      const realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
    inputaside(row,useType) {
      let usePanyMany = this.usegold*1 + this.useManey*1;
      console.log(this.message.orderPayAmount*1,usePanyMany);
      if (this.message.orderPayAmount < usePanyMany) {
        this.$message({
          message: "使用预留款金额和金币不得大于订单总价",
          type: "warning",
        });
        this.usegold = 0;
        this.useManey = 0;
        return;
      }
      if (useType == 'usegold' && this.message.userSpeciesNumber * 1 < row) {
        this.$message({
          message: "使用金币不得大于现有金币",
          type: "warning",
        });
        this.usegold = this.message.userSpeciesNumber * 1;
      }
      if (useType == 'useManey' && this.message.userMoneyNumber * 1 < row) {
        this.$message({
          message: "使用余额不得大于现有余额",
          type: "warning",
        });
        this.useManey = this.message.userMoneyNumber * 1;
      }
      
    },
    // 点击取消时 返回列表页面
    cancel() {
      this.$router.push("/flight/processorders");
    },
    // 点击去支付弹框
    payfn() {
      this.dialogVisible = false;
      this.$router.push("/flight/processorders");
    },
    // 机票订单详情
    getorderFlightDetails() {
      let orderId =
        this.$route.params.orderId ||
        JSON.parse(localStorage.getItem("flyInfo")).orderId;
      console.log(orderId);
      this.$axios
        .getorderFlightDetails({
          orderId,
        })
        .then((res) => {
          if (res.code == "00000") {
            console.log(res);
            this.message = res.data;
            this.getUsrBackCardList();
            this.tableData = res.data.orderItemS;
            console.log(this.message);
          }
        });
    },
    // 改签订单详情
    getqueryOrderChange() {
      let orderId =
        this.$route.params.orderId ||
        JSON.parse(localStorage.getItem("flyInfo")).orderId;
      console.log(orderId);
      this.$axios
        .getorderFlightDetails({
          orderId
        })
        .then((res) => {
          if (res.code == "00000") {
            this.message = res.data;
            this.changeAmount = this.message.changeRefundS[0].orderChangRefundItem.changeAmount;
            this.getUsrBackCardList();
            
            this.tableData = res.data.changeRefundS.filter((item)=>{
              if(item.orderChangRefundItem.orderStatus != "refundTicketSuccess" 
                && item.orderChangRefundItem.orderStatus != "refundTicketSuccess"){
                  return item
                }
            }).map((item,ind)=>{
              let obj = JSON.parse(JSON.stringify(item.orderChangRefundItem))
              obj['pnr'] = item.pnr;
              obj['orderId'] = item.orderId;
              return obj
            });
            this.message.orderItemS.forEach(item => {
              this.tableData.forEach((chItem)=>{
                if(chItem.orderItemId == item.id)chItem.idNumber = item.idNumber
              })
            });
          }
        });
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
          this.$router.push({
            name: "processorders",
            params: {
              orderId: this.orderId,
            },
          });
        })
        .catch((_) => {
          this.$router.push({
            name: "processorders",
            params: {
              orderId: this.orderId,
            },
          });
        });
    },

    endorse() {
      if(this.changeAmount == 0) this.showLoading();
      if(this.pattern.pays == "0") this.showLoading();
      if(this.pattern.pays == "3") this.showLoading();
      // debugger;
      if (this.type != 'change' && (this.message.orderPayAmount - this.usegold - this.useManey) == 0){
        this.$axios.getZeroPayment({
          orderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
          userMoneyNumber:this.useManey*1,
          userSpeciesNumber:this.usegold*1
        }).then((res)=>{
          this.closeLoading();
            if (res.code == "00000" && res.data &&res.data.IsSuccess) {
              this.$message({
                message: res.ErrorMsg,
                type: "success",
              });
              this.$router.push({
                name: "processorders",
                // params: { orderId: this.orderId },
              });
            } else{
              this.$message({
                message: res.data.ErrorMsg || res.msg,
                type: "success",
              });
              this.$router.push({
                name: "reserve",
                // params: { orderId: this.orderId },
              });
            }
        })
      }
      // if (this.type == 'change' && this.changeAmount == 0){
      //   this.$axios.getChangeZeroPayment({
      //     OrderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
      //     pnr: this.$route.params.pnr || JSON.parse(localStorage.getItem("flyInfo")).pnr
      //   }).then((res)=>{
      //     this.closeLoading();
      //       if (res.code == "00000" && res.data &&res.data.IsSuccess) {
      //         this.$message({
      //           message: res.ErrorMsg,
      //           type: "success",
      //         });
      //         this.$router.push({
      //           name: "processorders",
      //           // params: { orderId: this.orderId },
      //         });
      //       } else{
      //         this.$message({
      //           message: res.data.ErrorMsg || res.msg,
      //           type: "success",
      //         });
      //         this.$router.push({
      //           name: "reserve",
      //           // params: { orderId: this.orderId },
      //         });
      //       }
      //   })
      // }
      // if(this.changeAmount == 0){
      //   return false
      // }
      if (this.pattern.pays == "0") {
        if (!this.pattern.cardNumber) return;
        if (!this.tapycard) return;
        if (!this.pattern.userName) return;
        if (!this.pattern.cardId) return;
        if (!this.pattern.phone) return;
        let parmas = {
          orderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
          cardholder: this.pattern.userName, //持卡人姓名号
          cardNumber: this.pattern.cardId, //银行卡号
          cardType: this.tapycard,
          reservePhone: this.pattern.phone, //银行卡预留手机
          userCertificate: this.pattern.cardNumber, //身份证号
          orderSource: "crm",
        };
        if(this.type != 'change'){
          parmas['userMoneyNumber'] = this.useManey*1; // 积分
          parmas['userSpeciesNumber'] = this.usegold*1; //金币
        }
        if(this.tapycard === "creditcard") parmas["bankCode"] = this.pattern.bankCode
        if(this.tapycard === "creditcard") parmas["cvv2"] = this.pattern.cvv
        if(this.tapycard === "creditcard") parmas["creditFailureDate"] = this.pattern.creditFailureDate
        if (this.type == "change") {
          parmas["pnr"] = this.$route.params.pnr || JSON.parse(localStorage.getItem("flyInfo")).pnr
          this.$axios.getchangeBankCardPay(parmas).then((res) => {
            this.closeLoading();
            if (res.code == "00000" && res.data.ticketStatus.IsSuccess) {
              this.$message({
                message: res.data.errorMsg,
                type: "success",
              });
              this.$router.push({
                name: "processorders",
              });
            }else{
              this.$message({
                message: res.data.errorMsg || res.msg,
                type: "success",
              });
            }
          });
        } else {
          parmas["payAmount"] = this.message.orderPayAmount - this.usegold;
          this.$axios.getbankCardPayment(parmas).then((res) => {
            this.closeLoading();
            if (res.code == "00000" && res.data.ticketMessage.IsSuccess) {
              this.$message({
                message: res.errorMsg,
                type: "success",
              });
              this.$router.push({
                name: "processorders",
                // params: { orderId: this.orderId },
              });
            } else{
              this.$message({
                message: res.data.ticketMessage.ErrorMsg || res.data.errorMsg || res.msg,
                type: "success",
              });
              this.$router.push({
                name: "reserve",
                // params: { orderId: this.orderId },
              });
            }
          });
        }
      } else if (this.type == "change" && this.pattern.pays == "3") {
        this.$axios
          .getQRCodeChange({
              orderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
              pnr: this.$route.params.pnr || JSON.parse(localStorage.getItem("flyInfo")).pnr
          })
          .then((res) => {
            this.closeLoading()
            if (res.code == "00000") {
              console.log(res);
              this.dialogVisible = true;
              this.url = res.data.billQRCode;
              QRCode.toDataURL(this.url, {
                //这个this.url就是你扫码后要跳转的地址
                version: 7, //版本号
                errorCorrectionLevel: "Q", //容错率,(建议选较低)更高的级别可以识别更模糊的二维码，但会降低二维码的容量
                width: 280, //设置二维码图片大小
                height: 280,
              })
                .then((url) => {
                  console.log(url); //这个url是二维码生成地址，也就是相当于图片地址
                  this.qrcode = url; //赋值给变量。用在img的src属性上
                })
                .catch((err) => {
                  console.error(err);
                });
            }
          });
        // 银行卡支付与未支付订单支付
      } else if (this.type == "waitpay" && this.pattern.pays == "3") {
        if (this.$route.params.qrCode) {
          this.dialogVisible = true;
          QRCode.toDataURL(this.$route.params.qrCode, {
            //这个this.url就是你扫码后要跳转的地址
            version: 7, //版本号
            errorCorrectionLevel: "Q", //容错率,(建议选较低)更高的级别可以识别更模糊的二维码，但会降低二维码的容量
            width: 280, //设置二维码图片大小
            height: 280,
          })
            .then((url) => {
              this.closeLoading()
              console.log(url); //这个url是二维码生成地址，也就是相当于图片地址
              this.qrcode = url; //赋值给变量。用在img的src属性上
            })
            .catch((err) => {
              console.log("YOUCUO");
              // console.error(err);
            });
        } else {
          this.$axios
            .getgetQRCode({
              orderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
              userMoneyNumber:this.useManey*1,
              userSpeciesNumber:this.usegold*1
            })
            .then((res) => {
              this.closeLoading()
              console.log(res);
              this.dialogVisible = true;
              this.url = res.data.billQRCode;
              QRCode.toDataURL(this.url, {
                //这个this.url就是你扫码后要跳转的地址
                version: 7, //版本号
                errorCorrectionLevel: "Q", //容错率,(建议选较低)更高的级别可以识别更模糊的二维码，但会降低二维码的容量
                width: 280, //设置二维码图片大小
                height: 280,
              })
                .then((url) => {
                  console.log(url); //这个url是二维码生成地址，也就是相当于图片地址
                  this.qrcode = url; //赋值给变量。用在img的src属性上
                })
                .catch((err) => {
                  console.error(err);
                });
            });
        }
      } else if (!this.type  && this.pattern.pays == "3") {
        if (this.$route.params.qrCode) {
          this.dialogVisible = true;
          QRCode.toDataURL(this.$route.params.qrCode, {
            //这个this.url就是你扫码后要跳转的地址
            version: 7, //版本号
            errorCorrectionLevel: "Q", //容错率,(建议选较低)更高的级别可以识别更模糊的二维码，但会降低二维码的容量
            width: 280, //设置二维码图片大小
            height: 280,
          })
            .then((url) => {
              // this.closeLoading()
              console.log(url); //这个url是二维码生成地址，也就是相当于图片地址
              this.qrcode = url; //赋值给变量。用在img的src属性上
            })
            .catch((err) => {
              console.log("YOUCUO");
              // console.error(err);
            });
        } else {
          this.$axios
            .getgetQRCode({
              orderId:  this.$route.params.orderId || JSON.parse(localStorage.getItem("flyInfo")).orderId, //订单id
              userMoneyNumber:this.useManey*1,
              userSpeciesNumber:this.usegold*1
            })
            .then((res) => {
              this.closeLoading();
              this.dialogVisible = true;
              this.url = res.data.billQRCode;
              QRCode.toDataURL(res.data.billQRCode, {
                //这个this.url就是你扫码后要跳转的地址
                version: 7, //版本号
                errorCorrectionLevel: "Q", //容错率,(建议选较低)更高的级别可以识别更模糊的二维码，但会降低二维码的容量
                width: 280, //设置二维码图片大小
                height: 280,
              })
                .then((url) => {
                  // this.closeLoading()
                  console.log(url); //这个url是二维码生成地址，也就是相当于图片地址
                  this.qrcode = url; //赋值给变量。用在img的src属性上
                })
                .catch((err) => {
                  console.log("YOUCUO");
                  // console.error(err);
                });
            });
        }
      }
    },
    // 页面加载事件
    showLoading() {
      this.tableLoading = this.$loading({
        text: "拼命加载数据中", //显示在加载图标下方的加载文案
        spinner: "el-icon-loading", //自定义加载图标类名
        background: "rgba(0, 0, 0, 0.4)", //遮罩层颜色
        target: document.querySelector("#table"), //loadin覆盖的dom元素节点
      });
    },
    closeLoading() {
      this.tableLoading.close();
    },
  },
  mounted() {
    let flyInfo = JSON.parse(localStorage.getItem("flyInfo"));
    this.type = this.$route.params.type || flyInfo.type
    if (this.type == "change") {
      // this.getorderFlightDetails();
      this.getqueryOrderChange();
    } else {
      this.getorderFlightDetails();
    }
    // console.log(this.$route.params.orderId);
    // console.log(this.$route.params.payamount);
    console.log(flyInfo);
    this.Querydata = this.$route.params.Querydata || flyInfo.Querydata || {};
    // console.log( this.Querydata )
  },
};
</script>

<style scoped>
.pay {
  height: 100%;
  background-color: #f7f7f7;
}

.pay_1 {
  width: 1000px;
  background-color: #fff;
  margin: auto;
}

.top_1 {
  /* width: 80%; */
  display: flex;
  margin-left: 20px;
  margin-top: 30px;
}

.seven {
  margin-left: 20px;
}

.tuo {
  font-weight: bolder;
  display: flex;
  line-height: 41px;
  align-items: center;
}

.tuo-2 {
  width: 3.5px;
  height: 17px;
  background-color: #4b71bf;
  margin-right: 4px;
  font-size: 12px;
}

.others {
  display: flex;
  flex-direction: column;
  background-color: #f5f8f9;
  padding-top: 20px;
}

.five-2 {
  display: flex;
  align-items: center;
  font-size: 12px;
}

.five-3 {
  display: flex;
  flex-direction: column;
}

.WeChat1 {
  display: flex;
  height: 40px;
  align-items: center;
}

.five_t {
  font-size: 12px;
  margin-right: 5px;
}

.WeChat {
  color: #8aa2ae;
  font-size: 13px;
}
</style>